package com.urfresh.sp.flume.test;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import java.lang.reflect.Type;

/**
 * Created by urfresh.mark on 2016/9/8.
 */
public class ClickSerializer implements JsonSerializer<Click> {

    public JsonElement serialize(Click click, Type type, JsonSerializationContext context) {
        JsonObject object = new JsonObject();

        //此处按需要实际排序的顺序添加到JsonObject对象中
        object.add("type", context.serialize(click.getType()));
        object.add("name", context.serialize(click.getName()));
        object.add("count", context.serialize(click.getCount()));
        object.add("value", context.serialize(click.getValue()));
        return object;
    }

    public static void main(String[] args) {
//        int i = (1*1*1)+(2*-2*2)+(2*2*-2)-(1*-2*-2)-(2*2*1)-(2*3*2);
        int i= (1*1*1)+(-1*-1*1)+(1*1*1)-(1*-1*1)-(-1*1*1)-(1*1*1);
//        int i = (2*0*2*1)+(1*1*3*2)+(-2*1*0*0)+(4*3*-1*5) -
//                (2*1*2*0)-(1*3*3*5)-(-2*0*0*1)-(4*1*-1*2);
        System.out.println(i);

    }
}
